function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

/**
 * @Author: ls <ls-mac>
 * @Date:   2020-05-18 14:14:57
 * @Last modified by:   ls-mac
 * @Last modified time: 2020-05-20 13:58:57
 */
var mapDemo = /*#__PURE__*/function () {
  "use strict";

  function mapDemo() {
    _classCallCheck(this, mapDemo);

    this.map = new BMap.Map("mapContainer");
    this.labelStyle = {
      // 设置label的样式
      color: "#fff",
      width: "200px",
      height: "100px",
      padding: "20px",
      fontSize: "16px",
      borderRadius: "6px"
    };
  }

  _createClass(mapDemo, [{
    key: "init",
    value: function init() {
      // 118.78, 32.04
      var point = new BMap.Point(119, 35);
      this.map.centerAndZoom(point, 6);
      this.renderPointMotor();
      this.renderPointMotor2();
      this.renderPointRail();
      this.renderPointRail2();
      this.renderPointWater();
      this.renderPointWater2();
    } // 渲染汽运点

  }, {
    key: "renderPointMotor",
    value: function renderPointMotor() {
      var o = {
        lat: 40.058692,
        lng: 116.30799
      };
      var point = new BMap.Point(o.lng, o.lat);
      var myIcon = new BMap.Icon("../../assets/img/map-images/map-motor.png", new BMap.Size(44, 56));
      var marker = new BMap.Marker(point, {
        icon: myIcon
      }); // 创建标注

      this.map.addOverlay(marker);
    } // 渲染当前汽运点

  }, {
    key: "renderPointMotor2",
    value: function renderPointMotor2() {
      var o = {
        lat: 43.058692,
        lng: 116.30799
      };
      var point = new BMap.Point(o.lng, o.lat);
      var myIcon = new BMap.Icon("../../assets/img/map-images/map-motor2.png", new BMap.Size(44, 56));
      var marker = new BMap.Marker(point, {
        icon: myIcon
      }); // 创建标注

      this.map.addOverlay(marker); // 渲染标注

      var content = "<div class='map-label-conatiner map-label-motor'>1111</div>";
      var label = new BMap.Label(content, {
        // 创建文本标注
        position: point,
        offset: new BMap.Size(-120, -200)
      });
      this.map.addOverlay(label); // 将标注添加到地图中

      label.setStyle(_objectSpread({}, this.labelStyle, {}, {
        background: "rgba(0,164,234,1)",
        border: "4px solid rgba(0,102,195,1)"
      }));
    } // 渲染水运点

  }, {
    key: "renderPointWater",
    value: function renderPointWater() {
      var o = {
        lat: 36.9,
        lng: 112.425
      };
      var point = new BMap.Point(o.lng, o.lat);
      var myIcon = new BMap.Icon("../../assets/img/map-images/map-water.png", new BMap.Size(44, 56));
      var marker = new BMap.Marker(point, {
        icon: myIcon
      }); // 创建标注

      this.map.addOverlay(marker);
    } // 渲染当前水运点

  }, {
    key: "renderPointWater2",
    value: function renderPointWater2() {
      var o = {
        lat: 32.9,
        lng: 99.425
      };
      var point = new BMap.Point(o.lng, o.lat);
      var myIcon = new BMap.Icon("../../assets/img/map-images/map-water2.png", new BMap.Size(44, 56));
      var marker = new BMap.Marker(point, {
        icon: myIcon
      }); // 创建标注

      this.map.addOverlay(marker); // 渲染标注

      var content = "<div class='map-label-conatiner map-label-water'>1111</div>";
      var label = new BMap.Label(content, {
        // 创建文本标注
        position: point,
        offset: new BMap.Size(-120, -200)
      });
      this.map.addOverlay(label); // 将标注添加到地图中

      label.setStyle(_objectSpread({}, this.labelStyle, {}, {
        background: "rgba(153,176,0,1)",
        border: "4px solid rgba(104,120,0,1)"
      }));
    } // 渲染铁运点

  }, {
    key: "renderPointRail",
    value: function renderPointRail() {
      var o = {
        lat: 34.9,
        lng: 116.425
      };
      var point = new BMap.Point(o.lng, o.lat);
      var myIcon = new BMap.Icon("../../assets/img/map-images/map-rail.png", new BMap.Size(44, 56));
      var marker = new BMap.Marker(point, {
        icon: myIcon
      }); // 创建标注

      this.map.addOverlay(marker);
    } // 渲染当前铁运点

  }, {
    key: "renderPointRail2",
    value: function renderPointRail2() {
      var o = {
        lat: 31.9,
        lng: 130.425
      };
      var point = new BMap.Point(o.lng, o.lat);
      var myIcon = new BMap.Icon("../../assets/img/map-images/map-rail2.png", new BMap.Size(44, 56));
      var marker = new BMap.Marker(point, {
        icon: myIcon
      }); // 创建标注

      this.map.addOverlay(marker); // 渲染标注

      var content = '<div class="map-label-conatiner map-label-rail">11211</div>';
      var label = new BMap.Label(content, {
        // 创建文本标注
        position: point,
        offset: new BMap.Size(-120, -200)
      });
      this.map.addOverlay(label); // 将标注添加到地图中

      label.setStyle(_objectSpread({}, this.labelStyle, {}, {
        background: "rgba(255,114,84,1)",
        border: "4px solid rgba(176,35,35,1)"
      }));
    }
  }]);

  return mapDemo;
}();

$(function () {
  var map = new mapDemo();
  map.init();
});
